package com.yanqu.road.server.logic.task.condition;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.task.TaskConditionInfo;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.task.BaseCondition;
import com.yanqu.road.server.logic.task.BaseTaskData;

import java.math.BigInteger;

/**
 * 药铺处方总等级 成就
 */
public class DrugStoreChuFangLevelCondition extends BaseCondition {

    public DrugStoreChuFangLevelCondition(TaskConditionInfo taskConditionInfo, BaseTaskData baseTaskData, BigInteger value, Object initArgs) {
        super(taskConditionInfo, baseTaskData, value, initArgs);
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.DrugStoreChuFangLevel.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.DrugStoreChuFangLevel.getValue(), handle);
    }

    @Override
    public boolean isCompleted(GamePlayer player) {
        if(getValue().compareTo(taskConditionInfo.getParamList().get(3)) >= 0){
            return true;
        }
        return false;
    }

    @Override
    protected void changeValue(Object object) {
        BigInteger value = (BigInteger) object;
        setValue(value);
    }
}
